package com.ky.pro.java.dt.order;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class CodeGenerator {


    public static void main(String[] args) {

        String url = "jdbc:mysql://127.0.0.1:3306/food2go?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true";
        String ourDir = "/home/kevin/opt/codes/Codes/git/geekbang/pro-java/08-SHARDING&DT/hmily-demo/hmily-demo-order-service/src/main";

        FastAutoGenerator.create(url, "kevin", "123456")
                .globalConfig(builder -> {
                    builder.author("Kevin Dummy") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir(ourDir + "/java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.ky.pro.java.dt") // 设置父包名
                            .moduleName("order") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, ourDir + "/resources/mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> builder.addInclude("t_order")
                        .addTablePrefix("t_")// 设置过滤表前缀
                        .entityBuilder().enableLombok())
                .execute();
    }

}
